import Vue from 'vue'
import Vuex from 'vuex'
import { request } from '@/utils/wx'
import { apiDomain } from '@/utils/constant'

Vue.use(Vuex)

const API = {
  /** 机器人客服问题列表，POST */
  selectRobotCustomerListByLanguage: `${apiDomain}/api/route/selectRobotCustomerListByLanguage`,
  /** 机器人客服单个问题回答详情，POST */
  selectRobotCustomerById: `${apiDomain}/api/route/selectRobotCustomerById`,
  /** 根据运单号获取运单路由轨迹，POST */
  selectRouteTrackByNo: `${apiDomain}/api/route/selectRouteTrackByNo`,
}

const store = new Vuex.Store({
  state: {
    expressInquiryResult: {}
  },
  mutations: {},
  actions: {
    // 机器人客服问题列表
    async selectRobotCustomerListByLanguage ({ state }, data) {
      const res = await request({
        method: 'POST',
        url: API.selectRobotCustomerListByLanguage,
        data
      })
      return res
    },
    // 机器人客服单个问题回答详情
    async selectRobotCustomerById ({ state }, data) {
      const res = await request({
        method: 'POST',
        url: API.selectRobotCustomerById,
        data
      })
      return res
    },
    // 根据运单号获取运单路由轨迹
    async selectRouteTrackByNo ({ state }, data) {
      const res = await request({
        method: 'POST',
        url: API.selectRouteTrackByNo,
        data
      })
      return res
    },
  }
})

export default store
